﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Coin : MonoBehaviour {

    private Rigidbody2D rg;
    private BoxCollider2D ca;
    
    private void OnCollisionEnter2D(Collision2D other)
    {
        
        if (other.gameObject.tag == "Player")
        {
            CoinController.con.Au1Play();
            ca.enabled = false;
            rg.simulated = false;
            Destroy(gameObject);
            GameController.con.AddCoin(1);
        }
    }
    // Use this for initialization
    void Start () {
        ca = GetComponent<BoxCollider2D>();
        rg = GetComponent<Rigidbody2D>();
        transform.position += new Vector3(Random.Range(-2, 2), Random.Range(8, 14), 0);
        
    }
	
	// Update is called once per frame
	void Update () {
		
	}
}
